#include <iostream>
#include <map>
using namespace std;

int main() {
    int N;
    cin >> N;

    // counter[x] : the number of i satisfying x = i + A[i]
    map<int, int> counter;

    long ans = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        // Add the count satisfying j - A[j] = i + A[i]
        ans += counter[i - a];
        // increment the counter for j + A[j]
        ++counter[i + a];
    }
    cout << ans << endl;
    return 0;
}
